-- SceneSequence
-- create by chendh
-- 场景表现的流程控制(界面表现)

require("game/ui/base/ActionState");
require("game/ui/scene_sequence/action/ActionBase");
require("game/ui/scene_sequence/action/LaunchAction");

-- 技能施展的播放序列
SceneSequence = class("SceneSequence");

--构造函数
function SceneSequence:ctor()
    -- 初始化
    self.actionSequence = {};
end

-- 添加行为表现
function SceneSequence:addAction(action, fromPos, toPos, args)
    if action == "launch" then
        self:launch(fromPos, toPos, args);
    end
end

-- 判断是否有序列需要播放
function SceneSequence:isEmpty()
    local num = #self.actionSequence;
    return num == 0;
end

-- 播放序列, 每次只播放一个，并返回当前序列需要的时间
function SceneSequence:play()
    for i = 1, #self.actionSequence do
        local action = self.actionSequence[i];
        table.removeItem(self.actionSequence, action);
        return action:play();
    end
end

-- 添加投掷行为表现
function SceneSequence:launch(fromPos, toPos, args)
    -- 投掷行为
    table.insert(self.actionSequence, LaunchAction.create(fromPos, toPos, args));
end

return SceneSequence;
